<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>阉 - 非法信息自查 system － project OOXX </title>
</head>

<body>
<?php
/*
 Authour BigCat.
 QQ/GTALK/MSN/EMAIL i@ooxx.me
   28 Feb 2009
   
*/
set_time_limit(0);
$domain = $_POST['domain'];
$engine = $_POST['engine'];

class googleCounter{
                          function url($search,$engine) {
                        
                              if($engine == 'g'){
                                    return "http://www.google.cn/search?hl=zh-CN&q=".$search."&btnG=Search&meta=";
                                   }else{
                                    return "http://www.baidu.com/s?wd=".$search;
                                   }
                          }
                          function counter($search,$engine) {

                               
                               $search = urlencode($search);           //
                               
                              
                               $curl = curl_init();

                               if($engine == 'g'){
                                 $url = "http://www.google.cn/search?hl=zh-CN&q=".$search."&btnG=Search&meta=";
                               }else{
                                 $url = "http://www.baidu.com/s?wd=".$search;
                               }
                        
                               curl_setopt($curl, CURLOPT_URL, $url);
                        
                               curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                               
                               $result=curl_exec ($curl);
                         
                               $error = curl_error($curl);
                        
                               $errorno = curl_errno($curl);
                        
                               curl_close ($curl);
			                   $result=iconv("GB2312","UTF-8",$result);
                              if($engine == 'g'){
                                  preg_match('/约有 <b>.*[<][^a-z]b> 项符合/',$result,$matches);

                                  return substr($matches[0],strpos($matches[0],'约有')+10,-10);
                               }else{
                                  preg_match('/相关网页约.*篇/',$result,$matches);
                                  
                                  return substr($matches[0],strpos($matches[0],'相关网页约')+15,-3);
                                     }
                               }
                             
   }

$g = new googleCounter();
$resultNo =  $g->counter($domain,$engine);
$url = $g->url($domain,$engine);
echo "<strong>$domain</strong>'s results ____".$resultNo.'<br />';
echo '<a href="'.$url.'" target="_blank">'.$url.'</a>';


?>


<form action="" method="post" onsubmit="return ooxx()">
<label><input type="radio" name="engine" value ="g" <?php if($engine=='g'){echo 'checked="checked"';} ?> /> Google </label>
<label><input type="radio" name="engine" value ="b" <?php if($engine=='b'){echo 'checked="checked"';} ?> /> Baidu </label>
<input type="text" name='domain' value="<?php echo $domain ?>" />
<input type="submit" />
</form>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
             function ooxx(){
             var domain
             }
</script>

         </body>
         </html>
         


